package in.muton.edushare.pages.univ;

import in.muton.edushare.url.URLLoader;
import in.muton.edushare.wicket.models.CayenneList;
import in.muton.edushare.wicket.models.InnerList;
import in.muton.panels.paginator.EntityListing;

import java.util.List;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.model.IModel;

import com.edushare.common.constants.ApplicationConstants;
import com.edushare.common.constants.URLConstants;
import com.edushare.common.vo.Groups;

public class UnivGroups extends UnivBase {

	public UnivGroups(PageParameters params) {
		super(params);
		PageParameters pp = new PageParameters();
		pp.add("v", "create");
		BookmarkablePageLink<Void> newGroupLink = new BookmarkablePageLink<Void>(
				"createAGroup", URLLoader
						.getPageClass(URLConstants.USER_GROUPS), pp);
		add(newGroupLink);
		add(new EntityListing<Groups>("thumbList", new InnerList<Groups>() {
			private static final long serialVersionUID = -5396409052930253629L;

			@Override
			public List<IModel<Groups>> getObject() {
				return new CayenneList<Groups>(getUnivGroups()).getObject();
			}
		}, this));

	}

	@Override
	public String getActivePage(PageParameters p) {
		return "UnivGroups";
	}

	@Override
	public String getPageTitle() {
		return "Groups | " + super.getModel().getObject().getUniversityName()
				+ " | " + ApplicationConstants.APPLICATION_NAME;
	}

	public List<Groups> getUnivGroups() {
		return super.getModel().getObject().getGroups();
	}

}
